﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

using Framework.Graphics;

namespace Framework.GameStateManagment.GameScreens
{
    class LoadingScreenBegin : GameScreen
    {
        private Texture2D _loadingBar;
        private Rectangle _rectLoadingBar;
        private Texture2D _backgroundPic;
        private Texture2D _loadingBarBackground;
        private SpriteFont _font, _infoFont;

        public Texture2D LoadingBar
        {
            get { return _loadingBar; }
            set { _loadingBar = value; }
        }

        public Rectangle RectLoadingBar
        {
            get { return _rectLoadingBar; }
            set { _rectLoadingBar = value; }
        }


        public override void LoadContent(ContentManager Content)
        {
            _loadingBar = Content.Load<Texture2D>(@"GameScreen\LoadingScreenBeginn\LadeBalken");
            _backgroundPic = Content.Load<Texture2D>(@"GameScreen\LoadingScreenBeginn\LadeScreen1");
            _loadingBarBackground = Content.Load<Texture2D>(@"GameScreen\LoadingScreenBeginn\Hintergrund");
            _font = Content.Load<SpriteFont>(@"Font\Font");
            _infoFont = Content.Load<SpriteFont>(@"Font\InfoFont");
            _rectLoadingBar = new Rectangle(150, 700, 0, _loadingBar.Height);

        }

        public override void Update()
        {
            if (_rectLoadingBar.Width < _loadingBar.Width)
            {
                _rectLoadingBar.Width = _rectLoadingBar.Width + 7;
            }
            else
            {
                 if (Input.KS.IsKeyDown(Keys.Space))
                {
                    GameStateManagment.GameState = 1;
                }
            }
        }

        public override void Draw()
        {
            GameStateManagment.SpriteBatch.Begin();
            Camera.TryDraw(_backgroundPic, new Vector2(0, 0), Color.White);
            Camera.TryDraw(_loadingBarBackground, new Vector2(142, 697), Color.White);
            GameStateManagment.SpriteBatch.Draw(_loadingBar, _rectLoadingBar, Color.White);
            if (_rectLoadingBar.Width >= _loadingBar.Width) //Ladebalken.Width)
            {
                GameStateManagment.SpriteBatch.DrawString(_font, "Press Space to Enter", new Vector2(400, 650), Color.White);
            }
            GameStateManagment.SpriteBatch.DrawString(_infoFont, "Robot War 0.07 alpha", new Vector2(5, 10), Color.White);
            GameStateManagment.SpriteBatch.DrawString(_infoFont, "Programming by Dominik ...", new Vector2(5, 25), Color.White);
            GameStateManagment.SpriteBatch.DrawString(_infoFont, "Graphic Design by Thiago ...", new Vector2(5, 40), Color.White);
            GameStateManagment.SpriteBatch.End();
        }
    }
}